#include<iostream>
#include<cstdio>
using namespace std;
int x[100005],y[100005],d[100005];
int c[100005];
int *a[100005];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for (int i=1;i<=k;i++)
	{
		cin>>x[i]>>y[i]>>d[i];
		c[y[i]]++;
	}
	for (int i=1;i<=m;i++) a[i]=new int[c[i]];
	for (int i=1;i<=k;i++)
	{
		*a[y[i]]=d[i];
		a[y[i]]++;
	}
	for (int i=1;i<=m;i++)
	{
		a[i]-=c[i];
		for (int j=1;j<=c[i];j++,a[i]++) printf("%d ",*a[i]);
	}
	
	return 0;
}